package package007

import org.junit.Test

/**
 * @author futao
 * Created on 2017/11/13 - 20:50.
 */
class TestClass {

    /**
     * 当这个case抛出这个异常的时候并不会报错而会通过
     */
    @Test(expected = NullPointerException::class)
    fun testCase001() {
        fun a(str: String?) {
//            val s = str ?: ""
            println(str?.length ?: throw NullPointerException("空指针异常"))
        }

        fun b(str: String) {
            println(str!!.length)
        }

        val str: String? = null
//        if (str.isNullOrBlank()) throw ClassNotFoundException()
        str ?: let { a(str) }
    }


    @Test(expected = NullPointerException::class)
    fun hh() {
        println("hhhhhhhhhh")
    }


    @Test
    fun testCase002(){
        val list = listOf(1, 20, "22", 212.0)
        val i=1
        val s="22"
        val f=22.0
        if (i in list) println("i in")
        if (s in list) println("s in")
        if (f in list) println("f in")
        list[0]

    }

}